/*
 * riocpplib.h
 *
 *  Created on: 2021年3月11日
 *      Author: root
 */

#ifndef RIOCPPLIB_H_
#define RIOCPPLIB_H_

/** @brief RapidIO mport handle */
struct rapidio_mport_handle {
	int fd;			/**< posix api compatible fd to be used with poll/select */
	uint8_t mport_id;
};

/** @brief RapidIO mport handle */
typedef struct rapidio_mport_handle *riomp_mport_t;

riomp_mport_t mport_hnd;

int bslRioWriteRemoteReg(uint32_t tgt_destid ,uint8_t tgt_hc,uint32_t offset,uint32_t data);
int bslRioWriteLocalReg(uint32_t offset,uint32_t data);

int bslRioReadRemoteReg(uint32_t tgt_destid ,uint8_t tgt_hc,uint32_t offset);
int bslRioReadLocalReg(uint32_t offset);

int bslRioSendDoorbell(uint32_t rioid, uint16_t dbval);
int bslRioRecvDoorbell(uint32_t rioid);


int bslRioSendData(uint16_t destid, uint64_t tgt_addr, void *buf,uint32_t size);
int bslRioRecvData(uint64_t rio_base,uint32_t ib_size);
void bslWaitInputSrioData();
int bslReleaseInbound();

int bslRioPortInit(int index);
int bslRioPortDestory();

int bslRioGetID();
int bslRioSetID(uint32_t ID);

void *bslRecvDatabuf;
uint64_t rio_base;
uint32_t ib_size;

#endif /* RIOCPPLIB_H_ */
